import {HYEventStore} from "hy-event-store"
import {getRecommend} from '../service/api_music'
// 共享状态 
const recommendStore = new HYEventStore({
  state:{
    upRanking:{},     // 飙升榜
    newRanking:{},    // 新歌榜
    hotRanking:{},    // 热门榜
    originRanking:{}, // 原创榜
  },
  actions:{
    getToplistDataAction(ctx){
      // 通过上下文 给recommend 赋值
      // 飙升榜 榜单id 19723756
      getRecommend("19723756").then(res=>{
        ctx.upRanking = res.data.playlist.tracks
      })
      getRecommend("3779629").then(res=>{
        ctx.newRanking = res.data.playlist
      })
      getRecommend("3778678").then(res=>{
        ctx.hotRanking = res.data.playlist
      })
      getRecommend("2884035").then(res=>{
        ctx.originRanking = res.data.playlist
      })
    }
  }
})
// 交给 index
export { recommendStore}